import { Component } from "react";
import { useNavigate } from "react-router";
import ModuleList from './moduleList'
import ModuleAdd from "./modal/moduleAdd";
import ModuleModify from "./modal/moduleModify";
import ButtonModal from "./modal/buttonModal";


class ModuleManage extends Component{
    constructor(props){
        super(props)
        this.state = {
            moduleList: {
                loading: true,
                changeFlag: true
            },
            moduleAdd: {
                visible: false,
            },
            moduleModify: {
                visible: false
            },
            buttonModal: {
                buttonList: {
                    loading: true,
                    changeFlag: true
                },
                visible: false
            }
        }
        this.setState = this.setState.bind(this)
    }
    
    
    // componentWillMount() {
    //     做判断，如果是超级管理员，才会显示模块管理权限
    //     if (!(JSON.parse(sessionStorage.getItem('role')).roleName === '超级管理员')){
    //         this.props.navigate(-1) 
    //         return
    //     }
    // }

    // 修改模块隐藏状态

    render(){
        return(
            <>
                <ModuleList state={this.state} setState={this.setState.bind(this)} />
                { this.state.moduleAdd.visible ? <ModuleAdd state={this.state} setState={this.setState.bind(this)} /> : null }
                { this.state.moduleModify.visible ?  <ModuleModify state={this.state} setState={this.setState.bind(this)} /> : null }
                <ButtonModal state={this.state} setState={this.setState.bind(this)} />
            </>
        )
    }
}



export default ModuleManage